# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-05
# @File : 2_hook_password.py

import frida
import sys

rdev = frida.get_remote_device()
pid = rdev.spawn("cmt.chinaway.com.lite")
session = rdev.attach(pid)

scr = """
function hook_RegisterNatives() {
    Java.perform(function () {
        var n1 = Java.use("cmt.chinaway.com.lite.q.n1");
        n1.a.implementation = function (str) {
            console.log("---------------------")
            console.log(str);
            var res = this.a(str);
            console.log(res);
            return res;
        };
    });
}

setImmediate(hook_RegisterNatives);
"""
script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
rdev.resume(pid)
sys.stdin.read()
